﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class WucLogin : System.Web.UI.UserControl
{
    User user = new User();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
       user.UserName=txtUname.Text;
        user.Password=txtPass.Text;
        user.Center = DDLCenter.SelectedValue;
        user.Job = RDoProfession.SelectedValue;
        if (user.LogIn())
        {
            Utility.CreateCookie("login", new string[] { "username", "Job" }, new string[] { txtUname.Text, RDoProfession.SelectedValue }, false, Response);
            if (RDoProfession.SelectedValue == "Administrator")
                Response.Redirect("Admin.aspx");
            else if (RDoProfession.SelectedValue == "Doctor")
                Response.Redirect("DoctorPage.aspx");
            else if (RDoProfession.SelectedValue == "Recieptionist")
                Response.Redirect("Recieptionist.aspx");
            else
                Response.Redirect("Analyser.aspx");
        }
        else
            lblMsg.Text = "User Name Or Password incorrect";
    }
}